<?php $__env->startSection('content'); ?>
    <div class="admin-content">
        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">物流运费</strong> /
                <small>Express Manage</small>
            </div>
        </div>
        <br/>
        <?php if(session('express')): ?>
            <div class="am-g">
                <div class="am-u-md-12">
                    <div class="am-alert am-alert-success">
                        <?php echo e(session('express')); ?>

                    </div>
                </div>
            </div>
        <?php endif; ?>

        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-6">
                <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <a class="am-btn am-btn-default" href="<?php echo e(route('shop.express.create')); ?>">
                            <span class="am-icon-plus"></span> 新增
                        </a>
                    </div>
                </div>
            </div>
        </div>

        <div class="am-g">
            <div class="am-u-sm-12">
                <form class="am-form">
                    <table class="am-table am-table-striped am-table-hover table-main">
                        <thead>
                        <tr>
                            <th>编号</th>
                            <th>物流名称</th>
                            <th>配送方式描述</th>
                            <th>运费 / 满额包邮</th>
                            <th>是否可用</th>
                            <th style="width:10%">排序</th>
                            <th class="table-set">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach($expresses as $express): ?>
                        <tr data-id="<?php echo e($express->id); ?>">
                            <td><?php echo e($express->id); ?></td>
                            <td><a href="<?php echo e($express->url); ?>" target=""><?php echo e($express->name); ?></a></td>
                            <td><?php echo e($express->desc); ?></td>

                            <td><?php echo e($express->shipping_money); ?> / <?php echo e($express->shipping_free); ?></td>
                            <td class="am-hide-sm-only">
                                <?php /*<span class="am-icon-check is_something" data-attr="is_enable"></span>*/ ?>
                                <?php echo is_show('is_enable',$express); ?>

                            </td>

                            <td class="am-hide-sm-only">
                                <input type="text" name="sort_order" class="am-input-sm" value="<?php echo e($express->sort_order); ?>">
                            </td>

                            <td>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <a class="am-btn am-btn-default am-btn-xs am-text-secondary" href="<?php echo e(route('shop.express.edit',[$express->id])); ?>">
                                            <span class="am-icon-list-alt"></span> 编辑
                                        </a>
                                        <a class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" href="<?php echo e(route('shop.express.destroy',[$express->id])); ?>"
                                           data-method="delete" data-token="<?php echo e(csrf_token()); ?>" data-confirm="确定删除吗？">
                                            <span class="am-icon-trash-o"></span> 删除
                                        </a>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <?php endforeach; ?>

                        </tbody>
                    </table>

                    <div class="am-cf">
                        <div class="am-fr">


                        </div>
                    </div>

                </form>
            </div>
        </div>

    </div>
    <?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>
    <script>
        $(function(){
            //用ajax实现是否可用切换
            $('.is_something').click(function(){
                var _this=$(this);
                var id=$(this).parents('tr').attr('data-id');
//                alert(id);
                $.ajax({
                    url:'/shop/express/is_enable',
                    data:{'id':id},
                    type:'patch',
                    success:function (data) {
                        console.log(data);
                        _this.toggleClass('am-icon-close am-icon-check');
                    }
                })

            })

            //用ajax实现更改排序
            $("input[name='sort_order']").change(function(){
                var _this=$(this);
                var data={
                    sort_order:$(this).val(),
                    id:$(this).parents('tr').attr('data-id')
                }


                $.ajax({
                    url:'/shop/express/sort_order',
                    data:data,
                    type:'patch',
                })




            })
        })
    </script>
    <?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>